<?php

namespace app\api\controller;

use think\Controller;
use think\Request;

class Login extends Controller
{
    /**
     * @return \think\response\Json
     * 登录方法
     */
    public function doLogin()
    {
        $code = input('code');
        if (empty($code)){
            return getJson(500,'未传入code');
        }
        $appId = "wxb16e2d3911b8998e";
        $secret = "83364a13bf6ef9509cef892841fa80f3";
        $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appId . "&secret=" . $secret . "&js_code=" . $code . "&grant_type=authorization_code";
        $res = geturl($url);
        return getJson(200, '可以', $res);
    }
}

